
public class SysTimer implements Runnable
{
	/**
	 * the delay of the timer
	 */
	int my_period; // in ms
	
	/**
	 * the CPU 
	 */
	CPU my_cpu;
	
	Scheduler my_scheduler;
	

	public SysTimer(CPU cpu, Scheduler scheduler, int the_period) throws InterruptedException
	{
		my_period = the_period;
		my_scheduler = scheduler;
		my_cpu = cpu;
		
		Thread timer = new Thread(this);
		
		timer.start();
	}


	@Override
	public void run() {
		while(true)
		{
			try {
				Thread.sleep(my_period);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			my_cpu.setNew_pid(my_scheduler.usePolicy());
			System.out.println("Device 0 (System Timer) produced an interrupt.");
		}		
	}
	

}
